import {Component} from 'react'

class Two extends Component{

    constructor(props){
        super(props)
        this.state={
            childMsg:""
        }
       
    }

    handleChange=(e)=>{
      this.setState({
        childMsg:e.target.value
      })
    }

    handleClick=()=>{

         this.props.mymethod(this.state.childMsg)
    }

    render(){
        return (
           <div>
               <h1>组件2</h1>
               <input value={this.state.childMsg} onChange={this.handleChange}/>
               <button onClick={this.handleClick}>传值为组件1</button>
            
           </div> 
        )

    }
}

export default Two

